home *** CD-ROM | disk | FTP | other *** search
/ Champak 66 / Vol 66.iso / games / bluep.swf / scripts / __Packages / Bullet.as next >
Encoding:
Text File  |  2013-04-24  |  1.6 KB  |  65 lines

  1. class Bullet extends MovieClip
  2. {
  3.    var moveX;
  4.    var moveY;
  5.    var _damage;
  6.    var _holdMovement;
  7.    var _enemy;
  8.    var removeCallback;
  9.    function Bullet()
  10.    {
  11.       super();
  12.       this.moveX = 0;
  13.       this.moveY = 0;
  14.       this._damage = 1;
  15.       this._holdMovement = false;
  16.    }
  17.    function SetMovement(myX, myY)
  18.    {
  19.       this.moveX = myX;
  20.       this.moveY = myY;
  21.    }
  22.    function onEnterFrame()
  23.    {
  24.       if(this._holdMovement == false)
  25.       {
  26.          this._x += this.moveX;
  27.          this._y += this.moveY;
  28.          this.outOfBounds();
  29.          if(this._enemy)
  30.          {
  31.             this.ifHitAvatar();
  32.          }
  33.       }
  34.    }
  35.    function ifHitAvatar()
  36.    {
  37.       if(this.hitTest(_root.pointer.pointerBody))
  38.       {
  39.          if(_root.playerLives >= 2)
  40.          {
  41.             var _loc4_ = "shield_hits2" + _root.getNextHighestDepth();
  42.             var _loc5_ = 1 + Math.floor(Math.random() * 360);
  43.             _root.attachMovie("shield_hits2",_loc4_,_root.getNextHighestDepth());
  44.             _root[_loc4_]._rotation = _root.pointer._rotation + _loc5_;
  45.             _root[_loc4_]._x = this._x;
  46.             _root[_loc4_]._y = this._y;
  47.          }
  48.          this.removeCallback(this._name);
  49.          this.removeMovieClip();
  50.          if(!_global.shieldOn)
  51.          {
  52.             _root.adjustLives();
  53.          }
  54.       }
  55.    }
  56.    function outOfBounds()
  57.    {
  58.       if(this._x < -50 || this._x > 550 || this._y < -50 || this._y > 550 || _global.pauseClicked)
  59.       {
  60.          this.removeCallback(this._name);
  61.          this.removeMovieClip();
  62.       }
  63.    }
  64. }
  65.